package it.ap.sa.acqua.settings.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.util.StopWatch;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import it.ap.sa.acqua.shared.web.AbstractCtrl;
import it.ap.sa.core.utils.LogUtil;

/**
 * Controller per la gestione delle piante
 * 
 * @author Alessandro Paolillo
 *
 */
@Controller(value = "Settings Controller")
@RequestMapping("/settingsCtrl")
public class SettingsController extends AbstractCtrl {

	private static final Logger logger = LoggerFactory.getLogger(SettingsController.class.getName());
	
	@Override
	@RequestMapping(value = "/changePassword")
	public ModelAndView loadPage(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String    idLog     = "loadPage";
		StopWatch stopWatch = LogUtil.startStopWatch(idLog);
		logger.info("Start " + idLog);
		try{
			ModelAndView  mav      		= new ModelAndView(this.getPathSettingsPages() + "changePassword");
			return mav;
		}finally{
			logger.info(LogUtil.endStopWatch(stopWatch));
		}
	}
	
	@RequestMapping(value = "/viewProfile")
	public ModelAndView loadViewProfilePage(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String    idLog     = "loadPage";
		StopWatch stopWatch = LogUtil.startStopWatch(idLog);
		logger.info("Start " + idLog);
		try{
			ModelAndView  mav      		= new ModelAndView(this.getPathSettingsPages() + "viewProfile");
			return mav;
		}finally{
			logger.info(LogUtil.endStopWatch(stopWatch));
		}
	}
	
	@RequestMapping(value = "/fishWishlist")
	public ModelAndView loadFishWishlistPage(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String    idLog     = "loadFishWishlistPage";
		StopWatch stopWatch = LogUtil.startStopWatch(idLog);
		logger.info("Start " + idLog);
		try{
			ModelAndView  mav      		= new ModelAndView(this.getPathSettingsPages() + "fishWishlist");
			return mav;
		}finally{
			logger.info(LogUtil.endStopWatch(stopWatch));
		}
	}
	
	@RequestMapping(value = "/plantWishlist")
	public ModelAndView loadPlantWishlistPage(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String    idLog     = "loadPlantWishlistPage";
		StopWatch stopWatch = LogUtil.startStopWatch(idLog);
		logger.info("Start " + idLog);
		try{
			ModelAndView  mav      		= new ModelAndView(this.getPathSettingsPages() + "plantWishlist");
			return mav;
		}finally{
			logger.info(LogUtil.endStopWatch(stopWatch));
		}
	}
}
